package com.qingmeng.project.controller;

import com.qingmeng.project.annotation.AuthCheck;
import com.qingmeng.project.common.BaseResponse;
import com.qingmeng.project.common.ResultUtils;
import com.qingmeng.project.model.vo.InterfaceInfoVo;
import com.qingmeng.project.service.CountInterfaceService;
import io.swagger.annotations.Api;
import io.swagger.v3.oas.annotations.Operation;
import lombok.extern.slf4j.Slf4j;
import org.apache.tomcat.util.http.ResponseUtil;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 接口调用统计
 */
@RestController
@RequestMapping("/count")
@Slf4j
@Api(tags = "接口调用统计")
public class CountInterfaceControlller {
    @Resource
    private CountInterfaceService countInterfaceService;

    /**
     *  统计接口调用次数
     * @return
     */
    @GetMapping("/interface")
    @AuthCheck(mustRole = "admin")
    @Operation(summary = "统计接口调用次数", description = "统计分析每个接口的调用次数，判断出接口的使用率，进一步调整")
    public BaseResponse<List<InterfaceInfoVo>> countInterface(){
        List<InterfaceInfoVo> interfaceInfoVos = countInterfaceService.countInterface();
        return ResultUtils.success(interfaceInfoVos);
    }
}
